

export default {
  // 日期时间渲染
  dateRenderer(date) {
    if (date == null) {
      return null
    }
    let dt = new Date(date)
    return dt.format('yyyy-MM-dd HH:mm:ss')
  },
  // 持续时间渲染
  durationRenderer(time) {
    var time = parseInt((time || 0) / 1000)
    var seconds = time
    var minutes = parseInt(seconds / 60)
    var hours = parseInt(minutes / 60)
    var day = parseInt(hours / 24)

    seconds = seconds % 60
    minutes = minutes % 60
    hours = hours % 24

    var buf = ''
    day && (buf += day + '天')
    hours && (buf += hours + '时')
    minutes && (buf += minutes + '分')
    seconds && (buf += seconds + '秒')

    return buf || '0'
  }
}
